#include <iostream>
#include <string>
#include <vector>

int main() {
    std::string wa;
    std::cin >> wa;
    
    std::string ri = "";
    std::string ir = "";
    bool iw = true;
    
    while (true) {
        try {
            ri = "";
            ir = "";
            
            if (wa.empty()) {
                break;
            }
            
            for (size_t ia = 0; ia < wa.length(); ia++) {
                if (ia + 1 < wa.length()) {
                    if (wa.substr(ia, 2) == "()" || wa.substr(ia, 2) == "[]" || wa.substr(ia, 2) == "{}" || wa.substr(ia, 2) == "<>") {
                        ri += std::to_string(ia);
                        ir += std::to_string(ia + 1);
                    }
                }
            }
            
            int wi = 0;
            
            for (size_t ap = 0; ap < ri.length(); ap++) {
                wa.erase(std::stoi(ri.substr(ap, 1)) - wi, 1);
                wi++;
                wa.erase(std::stoi(ir.substr(ap, 1)) - wi, 1);
                wi++;
            }
            
            if (wi == 0) {
                break;
            }
        } catch (...) {
            iw = false;
            break;
        }
    }
    
    if (iw && wa.empty()) {
        std::cout << "True" << std::endl;
    } else {
        std::cout << "False" << std::endl;
    }
    
    return 0;
}